import requests

# 请求方法
class SendMethod:
    @staticmethod
    def send_method(method, url, params=None, data=None):
        if method == "get":
            response = requests.get(url, params=params)
        elif method == "post":
            response = requests.post(url, data=data)
        else:
            response =None
            print("请求方式不正确")

        #响应结果
        result = {}
        if response is not None:
            result["status_code"] = response.status_code
            result["headers"] = response.headers
            result["boby"] = response.json()
            result["response_time"] =int(response.elapsed.microseconds / 1000)
            return result
        else:
            return response

if __name__ == '__main__':
    url = "http://127.0.0.1:8000/api/add_event/"
    body = {
        "eid": "123456",
        "name": "魅族发布会99p",
        "limit": "20",
        "status": "1",
        "address": "武汉源码时代",
        "start_time": "2022-07-21"
    }
    params ={
        "eid":"123456"
    }
    # print(SendMethod.send_method("post", url, data=body))
    sm=SendMethod.send_method("get",url=url,params=params)
    print(sm)
